import showToast from '@/utils/toast';
import { useEffect } from 'react';
import { connect } from 'react-redux';
import { useNavigate, useLocation } from 'react-router-dom';

const Personal = (props) => {
  const navigate = useNavigate(),
    location = useLocation();
  const { userInfo } = props;

  useEffect(() => {
    if (!userInfo.id) {
      showToast({
        content: '未登录，请先登录'
      });
      navigate(`/login?to=${location.pathname}`, { replace: true });
    }
  }, []);

  return (
    <div>
      <h1>Personal</h1>
    </div>
  );
};

export default connect((state) => state.base)(Personal);
